import java.util.Scanner;

public class HomeWork14_04{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        
        String cmd;
        while(true){
            System.out.print("please enter command: ");
            cmd = scan.next();
            if(CheckInput.checkCmd(cmd)){
                System.out.println("合法");
            }else{
                System.out.println("不合法");
            }
        }
    }
}

class CheckInput{
    public static boolean checkCmd(String cmd){
        if(cmd.charAt(cmd.length() - 1) == 'a'){
            return true;
        }
        return false;
    }
}